package com.wechat.pay.controller;

import com.alibaba.fastjson.JSONObject;
import com.wechat.pay.req.UnifiedorderReq;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * 微信支付挡板
 */
@RestController
@RequestMapping("/v3/pay")
public class WechatPayController {

    private Logger logger = LoggerFactory.getLogger(WechatPayController.class);


    /**
     * 微信支付统一下单接口
     */
    @RequestMapping(value = "/transactions/native",method = RequestMethod.POST)
    public String unifiedorder(@RequestBody UnifiedorderReq unifiedorderReq){

        logger.info("接收到支付请求，请求的参数：{}",unifiedorderReq);


        JSONObject jsonObject = new JSONObject();


        String pr = "test";

        String groupid = "00";

        String codeUrl = "http://127.0.0.1:1111/wxpay/bizpayurl?pr="+pr+"&groupid="+groupid;

//        "code_url": "weixin://wxpay/bizpayurl/up?pr=NwY5Mz9&groupid=00"
        jsonObject.put("code_url",codeUrl);

        return jsonObject.toJSONString();
    }
}
